﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElingOA6_Admin_DSJCJ.Common;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers
{
    /// <summary>
    /// 民主评议初始化
    /// </summary>
    /// 
    [OutputCache(Duration = 0, VaryByParam = "none")]
    public class PeerReviewInitController : AdminBaseController
    {
        //
        // GET: /Admin/PeerReviewInit/
        /// <summary>
        /// 民主评议初始化主页
        /// </summary>
        /// <returns>视图</returns>
        [AuthorityActionFilter("m_PeerReviewInit", Order = 1)]
        [LogPageActionFilter("民主评议初始化", Order = 2)]
        public ActionResult Index()
        {
            BLL.PeerReview peerReviewBll = new BLL.PeerReview();

            DataSet ds = peerReviewBll.GetIsFtatus();

            string isFstatus = "";
            if (ds.Tables[0].Rows.Count > 0)
            {
                isFstatus = ds.Tables[0].Rows[0]["FStatus"].ToString();
            }
            else 
            {
                isFstatus = "";
            }
            ViewData["isFstatus"] = isFstatus;


            ViewData["peerReviewID"] = ds.Tables[0].Rows[0]["FPeerReviewID"].ToString();

            return View();
        }

        /// <summary>
        /// 评议初始化
        /// </summary>
        /// <returns>根据字符判断是否成功</returns>
        public string Init(string peerReviewID)
        {
            string str = "";
            string entityNo = GlobalConstant.ENTITYNO;
            BLL.PeerReviewInit initBll = new BLL.PeerReviewInit();
            try 
            {
                initBll.Init(decimal.Parse(peerReviewID), entityNo);
                str = "Y";
            }
            catch (Exception)
            {
                str = "N";
            }
            return str;
        
        }

    }
}
